//
// Created by tcl on 2025/7/9.
//

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <pwd.h>
#include <sstream>
#include "global_defination/global_defination.h"

int main()
{

    std::string dir_path = WORK_SPACE_PATH + "/csv_test/";
    std::ifstream param_file(dir_path + "txt/csv_header_params.txt");
    if (!param_file.is_open()) {
        std::cerr << "Failed to open parameter file." << std::endl;
        return -1;
    }
    std::vector<std::string> params;
    std::string line;
    while (std::getline(param_file, line)) {
        if (!line.empty()) params.push_back(line);
    }
    param_file.close();

    std::ofstream file(dir_path + "csv/vofa+.header.csv");
    if (!file.is_open())
    {
        std::cerr << "Failed to open file: " << dir_path << std::endl;
        return -1;
    }

    // 写入CSV头
    std::ostringstream oss;
    for (size_t i = 0; i < params.size(); ++i) {
        oss << params[i];
        if (i < params.size() - 1) oss << ",";
    }
    oss << "\n";
    file << oss.str();

    // 添加一组数据（值为0）
    for (size_t i = 0; i < params.size(); ++i)
    {
        file << "0";
        if (i < params.size() - 1) file << ",";
    }
    file << std::endl;

    file.close();
    return 0;
}